local mou__qingzheng = fk.CreateSkill {

  name = "joy_mou__qingzheng",

  tags = {  },

}



mou__qingzheng:addEffect("active", {
  name = "joy_mou__qingzheng",
  anim_type = "control",
  target_num = 0,
  can_use = function(self, player)
    return player:usedSkillTimes(mou__qingzheng.name, Player.HistoryPhase) == 0
  end,
  target_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    local num = math.max(3 - player:getMark("@joy_mou__jianxiong"),0)
    local cards ={}
    if num > 0 then
    local suits = {"diamond","heart","club","spade"}
    local choices = room:askForChoices(player, suits, num, num, mou__qingzheng.name, "#joy_mou__qingzheng-choice:::"..num,false)
    for _, ch in ipairs(choices) do
      for _, c in ipairs(player.player_cards[Player.Hand]) do
        local suit = Fk:getCardById(c):getSuitString()
        if suit == ch then
          table.insertIfNeed(cards, c)
        end
      end
    end
    cards = table.filter(cards, function (id)
      return not player:prohibitDiscard(Fk:getCardById(id))
    end)
    if #cards > 0 then
      room:throwCard(cards, mou__qingzheng.name, player)
    end
    end
    if player.dead then return end
    local tars = {}
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if not p:isKongcheng() then
        table.insertIfNeed(tars,p.id)
      end
    end
    if #tars <= 0 then return end
    local tar = room:askForChoosePlayers(player,tars,1,1,"清正：选择一名其他角色，观看其手牌并弃置其中一个花色的所有牌。",mou__qingzheng.name,true)
    if #tar <= 0 then return end
    local to = room:getPlayerById(tar[1])
    local cids = to.player_cards[Player.Hand]
    local id1 = room:askForCardChosen(player, to, { card_data = { { "$Hand", cids }  } }, mou__qingzheng.name, "#joy_mou__qingzheng-throw")
    local cards1 = table.filter(cids, function(id) return Fk:getCardById(id).suit == Fk:getCardById(id1).suit end)
    room:throwCard(cards1, mou__qingzheng.name, to, player)
    if #cards > #cards1 and not to.dead then
      room:damage{ from = player, to = to, damage = 1, skillName = mou__qingzheng.name }
    end
    if not player.dead then
      local choices = {"getMark"}
      local n = "#joy_mou__jianxiong-getMark"
      if player:getMark("@joy_mou__jianxiong") ~= 0 then
        table.insert(choices,"removeMark")
        n = "#joy_mou__jianxiong-choose"
      end
      if player.room:askForSkillInvoke(player, mou__qingzheng.name, nil, n) then
        local choice = player.room:askForChoice(player,choices,mou__qingzheng.name)
        if choice == "getMark" then
          player.room:addPlayerMark(player,  "@joy_mou__jianxiong", 1)
        else
          player.room:removePlayerMark(player, "@joy_mou__jianxiong", 1)
        end
      end
    end
  end,
})

return mou__qingzheng